﻿@model IEnumerable<BaseCate>
<div style="height: 40px; line-height: 40px; padding: 0 10px;">
    <div class="pull-right" style="height: 40px; line-height: 40px;">
        <a href="#addOne-modal" data-toggle="modal" class="btn  btn-primary btn-large"><i
            class="icon-plus-sign icon-white"></i>新增</a>
        <a href="@Url.Action("List")" class="btn  btn-primary btn-large"><i class="icon-th-list icon-white">
        </i>返回列表</a>
    </div>
    <div style="height: 40px; line-height: 40px;">
        <h2 id="bigTitle">
            @ViewBag.Title
        </h2>
    </div>
</div>
<hr />
@Html.Partial("MessageTip")
<table class="table table-bordered">
    <thead>
        <tr>
            <th align="center">
                名称
            </th>
            <th align="center">
                操作
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (GADC.Domain.BaseCate obj in Model)
        {
            <tr>
                <td>
                    @obj.Name
                </td>
                <td>
                    <a class="operate" href='javascript:editCate(@obj.ID,"@obj.Name")'>编辑</a>
                    <a class="operate" href="javascript:Operating(-1,@obj.ID)">删除</a>
                    <br />
                </td>
            </tr>
        }
    </tbody>
</table>
<form id="hideForm" class="editForm" action='@Url.Action("CateOperate")' method="post">
<input type="hidden" id="Operate" name="Operate" />
<input type="hidden" id="ID" name="ID" />
</form>
<div class="modal hide fade" id="addOne-modal" data-backdrop="static" data-keyboard="false">
    <form id="cateForm" action='@Url.Action("CateList")' method="post">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
            ×</button>
        <h3 id="myModalLabel">
            新增分类</h3>
    </div>
    <br />
    <fieldset>
        <div class="span5">
            <input type="hidden" name="ID" id="cateID" />
            <input type="text" class="span5" name="Name" id="cateName" placeholder="输入类型名称" />
        </div>
        <div class="span1 offset2">
            <input type="submit" id="recipe-btn" value="保 存" class="btn btn-blue span1" />
        </div>
    </fieldset>
    </form>
</div>
@section scripts{
    <script type="text/javascript">
        function Operating(operateType, id) {
            if (operateType == -1) {
                if (!window.confirm("确定删除该记录?")) {
                    return false;
                }
            }

            $("#Operate").val(operateType);
            $("#ID").val(id);
            $("#hideForm").submit();
        }


        function editCate(id, name) {
            $("#cateID").val(id);
            $("#cateName").val(name);
            $('#addOne-modal').modal('show');
        }
    </script>
}
